package yang.VirtualMachine.chapter9.classStruct;

import java.io.IOException;
import java.io.InputStream;

import yang.VirtualMachine.chapter9.ClassBean;
import yang.VirtualMachine.chapter9.ClassUtil;
import yang.VirtualMachine.chapter9.Processer;

/**
 * 2字节，指向常量池，同上		2字节，接口数		每个2字节，指向常量池InterFace
 * this_class,super_class,interfaces_count,interface[interfaces_count]
 * @author xinxin
 */
public class ClassInfoProcesser implements Processer {
	
	@Override
	public void process(InputStream input) throws IOException {
		ClassBean bean = ClassBean.getInstance();
		
		int l = (int) ClassUtil.getNumByStream(input, 2);
		bean.thisClass = bean.constantPool[l].getValue();
		
		l = (int) ClassUtil.getNumByStream(input, 2);
		bean.superClass = bean.constantPool[l].getValue();
		
		l = (int) ClassUtil.getNumByStream(input, 2);
		bean.interfacesCount = l;
		
		bean.interfaces = new String[l];
		for (int i = 0; i < l; i++) {
			int index = (int) ClassUtil.getNumByStream(input, 2);
			bean.interfaces[i] = bean.constantPool[index].getValue();
		}
	}

}
